package day01.text02;


import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Text {
    public static void main(String[] args) {

        //定义一个公共变量 stock 代表库存


      /*  //创建Seller对象
        Seller seller = new Seller(stock);

        //线程1
        Thread t1 = new Thread(seller,"线程1");
        t1.start();
        //线程2
        Thread t2 = new Thread(seller,"线程2");
        t2.start();
        //线程3
        Thread t3 = new Thread(seller,"线程3");
        t3.start();*/
        Seller seller = new Seller();
        ThreadPoolExecutor tp = new ThreadPoolExecutor(2,3,2, TimeUnit.SECONDS,new ArrayBlockingQueue<>(3), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());

        tp.submit(seller);
        tp.submit(seller);
        tp.submit(seller);
        tp.submit(seller);tp.submit(seller);
        tp.submit(seller);tp.submit(seller);
        tp.submit(seller);

       tp.shutdown();
    }
}
